The present invention relates in general to a data processing system, and in particular, to the instrumentation of garbage collection in a data processing system.
In Java, as well as other programming languages such as Lisp and Smalltalk, memory management is automatically performed. Objects are allocated in a runtime data area called the heap, and are deallocated when no longer needed. In the Java context, the Java Virtual Machine (JVM) specification dictates that objects be deallocated when they are no longer required by the JVM. Deallocating an object that is no longer required by the executing software frees the space on the heap occupied by the object to be deallocated. The process by which objects in these languages, such as Java, are identified for deallocation, and the heap space which they occupy deallocated, when required, is referred to as garbage collection.
In addition to freeing space on the heap, the garbage collection process may compact the heap. In this way, the garbage collection process repairs fragmentation of the heap which occurs as objects of varying sizes are allocated on the heap during the course of execution of a Java or other language program which performs garbage collection. Thus, at a minimum, garbage collection must be done when there is insufficient space on the heap to allocate an object created by the executing software.
Although essential to the operation of the software, garbage collection consumes processing cycles that may otherwise be used by the executing application. In this respect, garbage collection may be costly. Moreover, errors in the garbage collection routines can cause failures in application software written in a programming environment which does garbage collection. Therefore, there is a need in the art for methods and apparatus which instrument the garbage collection process in a data processing system. Data generated by the instrumentation process may then be used to design changes in the garbage collection mechanism. The instrumentation apparatus and methods may then be used to generate data which may be analyzed to measure the effectiveness of any implemented changes.
The aforementioned needs are addressed by the present invention. Accordingly, there is provided, in a first form, a method of garbage collection instrumentation. The method includes the step of generating a trace file, in which the step of generating a trace file constitutes making a single pass analysis of each object on an object heap, and writing a plurality of object data retrieved in the single pass analysis to an output file.
There is also provided, in a second form, a data processing system for instrumenting garbage collection. The data processing system contains circuitry operable for generating a trace file, which includes circuitry operable for making a single pass analysis of each object on an object heap, and writing a plurality of object data retrieved in the single pass analysis to an output file.
Additionally, there is provided, in a third form, a computer program product operable for storage on program storage media, wherein the program product is operable for garbage collection instrumentation. The program product contains programming operable for generating a trace file, in which programming operable for generating a trace file includes programming operable for making a single pass analysis of each object on an object heap, and programming operable for writing a plurality of object data retrieved in the single pass analysis to an output file.
The foregoing has outlined rather broadly the features and technical advantages of the present invention in order that the detailed description of the invention that follows may be better understood. Additional features and advantages of the invention will be described hereinafter which form the subject of the claims of the invention.